package cn.legend.travel.destination.main.controller;

import cn.legend.travel.common.web.JsonResult;
import cn.legend.travel.destination.main.pojo.vo.CountInt;
import cn.legend.travel.destination.main.pojo.vo.GuideVO;
import cn.legend.travel.destination.main.service.IGuideService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.SearchHit;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/dict/guide")
@Validated
@Api(tags = "3.攻略")
public class GuideController {
    @Autowired
    private IGuideService guideService;
    @GetMapping("/guideList")
    @ApiOperation("查询相关攻略")
    @ApiOperationSupport(order = 430)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "目的地，默认为北京", required = true, dataType = "String", example = "北京"),
            @ApiImplicitParam(name = "type", value = "攻略类型，默认为0", required = true, dataType = "Integer", example = "0")
    })
    public JsonResult selectInt(@RequestParam String name,@RequestParam Integer type) {
        log.info("开始处理【根据目的地名称查询攻略】的请求，参数：{}", name);
        List<GuideVO> guideVOS = guideService.selectListByDestinationName(name,type);
        return JsonResult.ok(guideVOS);
    }
    @GetMapping("/guidesList")
    @ApiOperation("查询景点攻略")
    @ApiOperationSupport(order = 440)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "目的地，默认为北京", required = true, dataType = "String", example = "北京"),
            @ApiImplicitParam(name = "num", value = "0为最热门的攻略，1为最新攻略", required = true, dataType = "Integer", example = "0"),
    })
    public JsonResult selectGuideList(@RequestParam String name,@RequestParam Integer num) {
        log.info("开始处理【根据目的地名称查询攻略】的请求，参数：{}", name);
        List<GuideVO> guideVOS = guideService.selectListByName(name,num);
        return JsonResult.ok(guideVOS);
    }
    @GetMapping("/guidesList/byKeywords")
    @ApiOperation("查询攻略")
    @ApiOperationSupport(order = 440)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "keyword", value = "关键词", required = true, dataType = "String"),
    })
    public JsonResult selectGuideListByKeywords(@RequestParam String keyword) {
        log.info("开始处理【根据关键词称查询攻略】的请求，参数：{}", keyword);
        return JsonResult.ok(guideService.selectList(keyword));
    }
}
